import { BaseCommand, TSelectRanage, TMergeCell } from '../types/common.interface';
import { TableDatas } from '../cors/table-datas';
import { RenderTrigger } from '../cors/render-trigger';
export class RowHeightCommand extends BaseCommand {
    protected pastIsManualHeight: boolean;
    protected PastRowHeight: number;
    constructor(
        protected datas: TableDatas,
        protected renderTrigger: RenderTrigger,
        protected row: number, 
        protected height: number
    ) {
        super();
    }
    public execute() {
        let height = 1;
        if(this.height > height) {
            height = this.height;
        }
        let rowInstaince = this.datas.getRow(this.row);
        this.pastIsManualHeight = rowInstaince.isManualHeight;
        rowInstaince.isManualHeight = true;
        this.PastRowHeight = rowInstaince.getHeight();
        rowInstaince.setHeight(height);
        this.datas.setRow(rowInstaince, this.row);
        this.renderTrigger.triggerRenderAll();
        return true;
    }
    public redo() {
        let instance = this.datas.getRow(this.row);
        if(this.pastIsManualHeight == true) {
            instance.setHeight(this.PastRowHeight);
        } else {
            instance.isManualHeight = false;
        }
        this.renderTrigger.triggerRenderAll();
        return true;
    }
}